//
//  RoundCornerBtn.swift
//  RPay
//
//  Created by CharlieLiao on 2017/7/2.
//  Copyright © 2017年 Charlie. All rights reserved.
//

import UIKit

@IBDesignable

class RoundCornerBtn: UIButton {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUpLayer()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setUpLayer()
    }
    
    /// 按钮背景颜色
    @IBInspectable var btnBgColor: UIColor = UIColor.appTheme {
        didSet {
            setBackgroundImage(UIImage(graphics: btnBgColor), for: .normal)
        }
    }
    
    override func prepareForInterfaceBuilder() {
        super.prepareForInterfaceBuilder()
        setUpLayer()
    }
    
    func setUpLayer() {
        layer.masksToBounds = true
        layer.cornerRadius = 2
        
        setTitleColor(UIColor.white, for: .normal)
        
        setBackgroundImage(UIImage(graphics: UIColor.appTheme), for: .normal)
    }
    
}
